<include file="Public/header"/>

<div class="x-nav">
      <span class="layui-breadcrumb">

      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
          <input type="text" name="name"  placeholder="请输入商品名称" autocomplete="off" value="{:I('name')}" class="layui-input">
          <input type="text" name="code"  placeholder="请输入商品编码" autocomplete="off" value="{:I('code')}" class="layui-input">         
           <div class="layui-input-inline">
            <select name="classid">
              <option value="0">商品分类</option>
              <foreach name="info" item="v">
              	<option value="{$v.id}" <if condition="$v['id'] eq I('classid')"> selected="selected" </if>>{$v.name}</option>
              </foreach>
            </select>
          </div>
           <div class="layui-input-inline">
            <select name="is_shangjia">
              <option value="0">选择商品上架状态</option>
              <option value="1" <if condition="I('is_shangjia') eq 1"> selected="selected" </if>>上架</option>
              <option value="2" <if condition="I('is_shangjia') eq 2"> selected="selected" </if>>下架</option>
            </select>
          </div>
           <div class="layui-input-inline">
            <select name="is_top">
              <option value="0">选择商品置顶状态</option>
              <option value="1" <if condition="I('is_top') eq 1"> selected="selected" </if>>不置顶</option>
              <option value="2" <if condition="I('is_top') eq 2"> selected="selected" </if>>置顶</option>
            </select>
          </div>
           <div class="layui-input-inline">
            <select name="is_del">
              <option value="0">选择商品删除状态</option>
              <option value="1" <if condition="I('is_del') eq 1"> selected="selected" </if>>没有删除</option>
              <option value="2" <if condition="I('is_del') eq 2"> selected="selected" </if>>已删除</option>
            </select>
          </div>                              
                           
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
          <button class="layui-btn"   type="reset" >清空</button>

        </form>
      </div>
      <xblock>
        <a class="layui-btn" onclick="x_admin_show('添加商品','{:U('add')}')">添加商品</a>
        <button class="layui-btn layui-btn-danger" onclick="delAll('','{:U('del')}')"><i class="layui-icon"></i>永久删除</button>

        <span class="x-right" style="line-height:40px">共有数据：{$count} 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>商品名称</th>
            <th>商品条码</th>
            <th>排序</th>
            <th>商品分类</th>
            <th>团购价格|基础价格/单买价格</th>
            <th>虚售/已售/可售</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
        <volist name="list" id="vo">
          <tr>
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id={$vo['id']}><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td>{$vo['id']}</td>
            <td><img src="{$vo['thumb']}"style="width: 40px" border=0>{$vo['name']}</td>
            <td>{$vo['code']}</td>
            <td>{$vo['sort']}</td>
            <td>{$vo["classid"]}</td>
            <td>{$vo['tuan_price']}|{$vo['market_price']}</td>
            <td>{$vo['xuni_sale_num']}/{$vo['sale_num']}/{$vo['kucun']}</td>
            <td>
              <php>
                $text = $vo['is_shangjia'] == 1 ? '售卖中':'已下架';
                $class = $vo['is_shangjia'] == 1 ? 'layui-btn-normal':'layui-btn-danger'
              </php>
              <span   class="layui-btn  layui-btn-xs {$class} " onclick="setStatus(this,'{$vo['id']}','{:U('setStatus')}')">{$text}</span>
              <!--  
              <php>
                $text = $vo['is_top'] == 1 ? '不置顶':'置顶';
                $class = $vo['is_top'] == 1 ? 'layui-btn-normal':'layui-btn-danger'
              </php>
              <span   class="layui-btn  layui-btn-xs {$class} " onclick="setStatus(this,'{$vo['id']}','{:U('setTop')}')">{$text}</span>              
              -->
              <php>
                $text = $vo['is_del'] == 1 ? '没有删除':'已删除';
                $class = $vo['is_del'] == 1 ? 'layui-btn-normal':'layui-btn-danger'
              </php>
              <span   class="layui-btn  layui-btn-xs {$class} " onclick="setStatus(this,'{$vo['id']}','{:U('setDel')}')">{$text}</span>               
            </td>
            
            
            
            <td class="td-manage">
              <a title="编辑" class="layui-btn layui-btn-xs"  onclick="x_admin_show('商品编辑','{:U('edit',array('id'=>$vo['id']))}')" href="javascript:;">
                编辑
              </a>


            </td>
          </tr>
        </volist>


        </tbody>
      </table>
      <div class="page" id="page">
        {$page}
      </div>

    </div>
    <script>

      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

       /*用户-停用*/
      function member_stop(obj,id){
          layer.confirm('确认要停用吗？',function(index){

              if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

              }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
              }
              
          });
      }





    </script>

<include file="Public/footer"/>

